﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BrainTechLLC;

namespace UserInterface
{
	public partial class AssociatedIDControl : UserControl
	{
		protected long _item;

		[Bindable(BindableSupport.Yes)]
		public long Item
		{
			get { return _item; }
			set { _item = value; UpdateBindings(); }
		}

		public void UpdateBindings()
		{
			if (_item != 0)
			{
				txtID.Text = _item.ToString();
				IGameThing thing = Everything.Find<IGameThing>(_item);
				this.toolTip1.SetToolTip(this.txtID, thing == null ? "Invalid ID" : thing.ToString());
			}
		}

		public AssociatedIDControl()
		{
			InitializeComponent();
		}

		private void btnEdit_Click(object sender, EventArgs e)
		{
			EditorForm editor = new EditorForm();
			editor.Show();
			editor.SetItem(Everything.Find<IGameThing>(_item));
		}
	}
}
